#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <functional>

void printV(vector<int> &v)
{
        for (int i = 0; i < (int)v.size(); i++)
        {
                cout<<v[i] <<" ";
        }
        cout<<endl;
}

void test1()
{
        vector<int> v1, v2;
        v1.push_back(1);
        v1.push_back(3);
        v1.push_back(5);
        v1.push_back(7);

        v2.resize(v1.size());

        copy(v1.begin(), v1.end(), v2.begin());

        printV(v2);
}

bool greatFive(int &n){
        if(n > 5){
                return true;
        }
        return false;
}

void test2()
{
        vector<int> v1;
        v1.push_back(1);
        v1.push_back(3);
        v1.push_back(5);
        v1.push_back(7);       
        v1.push_back(3);

        replace(v1.begin(), v1.end(), 3, 8) ;
        printV(v1);      

        //大于5都变成1
        replace_if(v1.begin(), v1.end(), greatFive, 1);
        printV(v1);
}

void test3()
{
        vector<int> v1,v2;
        v1.push_back(1);
        v1.push_back(3);
        v1.push_back(5);

        v2.push_back(2);
        v2.push_back(4);
        v2.push_back(6);

        swap(v1, v2);
        printV(v1);
        printV(v2);
}

int main(int argc, char const *argv[])
{
        //test1();
        //test2();
        test3();
        return 0;
}
